/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package action;

import dao.ActivityHistoryCrud;
import java.sql.Connection;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import pojo.ActivityHistory;

/**
 *
 * @author A7med Kotb
 */
public class LSHistoryActionByName extends org.apache.struts.action.Action {

    /* forward name="success" path="" */
    private static final String SUCCESS = "success";

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception 
    {
        Connection c=getDataSource(request, "MyDS").getConnection();
        String activityName=request.getParameter("owner");
        StringBuffer result=new StringBuffer();
        Vector<ActivityHistory> pactivities=new ActivityHistoryCrud(c).getByLiveServerName(activityName);
        result.append(" <table border=\"1\">  <tr> <td> Admin-Name </td> <td> Activity-Name </td> <td> Activity-Time </td> <td> Activity-Description </td> <td> Status </td><td>Live-Server</td>  </tr>");
        for (int i = 0; i < pactivities.size(); i++) 
        {
                result.append("<tr><td> "+pactivities.get(i).getAdminName()+" </td> <td> "+pactivities.get(i).getActivityName()+" </td>"
                    + " <td>"+pactivities.get(i).getActivityTime()+" </td> <td>"+pactivities.get(i).getActivities().getDescription()+" </td> <td> "+pactivities.get(i).getStatus()+" </td> <td> "+pactivities.get(i).getLiveServer()+" </td> </tr>");
        }
        result.append("</table>");
        response.getWriter().println(result.toString());
        return null;    
    }
}
